//
//  UserGuideViewController.m
//  CatMusic
//
//  Created by dllo on 15/4/28.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "BaseTableViewController.h"
#import "MusicLibraryViewController.h"
#import "MyMusicViewController.h"
#import "RecommendViewController.h"
#import "SearchViewController.h"
//#import "CreatCollectionView.h"
#import "PlayerSingleton.h"
#import "UMSocial.h"
#import "UserGuideViewController.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height


@interface UserGuideViewController ()
@property (nonatomic, retain) UIScrollView *scrollView;
@end

@implementation UserGuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.scrollView = [[UIScrollView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width * 4, self.view.frame.size.height);
    [self.scrollView setPagingEnabled:YES];
    [self.view addSubview:self.scrollView];
    
    
    UIImageView *imageVeiw1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    [imageVeiw1 setImage:[UIImage imageNamed:@"c2"]];
    [self.scrollView addSubview:imageVeiw1];
    [imageVeiw1 release];
    
    UIImageView *imageVeiw2 = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH, 0, WIDTH, HEIGHT)];
    [imageVeiw2 setImage:[UIImage imageNamed:@"c1"]];
    [self.scrollView addSubview:imageVeiw2];
    [imageVeiw2 release];
    
    UIImageView *imageVeiw3 = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH * 2, 0, WIDTH, HEIGHT)];
    [imageVeiw3 setImage:[UIImage imageNamed:@"c3"]];
    [self.scrollView addSubview:imageVeiw3];
    [imageVeiw3 release];
    
    UIImageView *imageVeiw4 = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH * 3, 0, WIDTH, HEIGHT)];
    [imageVeiw4 setImage:[UIImage imageNamed:@"c4"]];
    [self.scrollView addSubview:imageVeiw4];
    [imageVeiw4 release];
    
    
    UIButton *endButton = [UIButton buttonWithType:UIButtonTypeSystem];
    endButton.frame = CGRectMake((WIDTH  / 2 ) * 7 - 40, HEIGHT / 667 *600 , WIDTH / WIDTH * 80, HEIGHT / 667 * 40);
    endButton.layer.borderWidth = 1;
    endButton.layer.cornerRadius = 5;
    endButton.tag = 1003;
    [endButton setTitle:@"立即体验" forState:UIControlStateNormal];
    [endButton addTarget:self action:@selector(endButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollView addSubview:endButton];
    
    
    
    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(switchBitrateAction:)];
    swipe.direction = UISwipeGestureRecognizerDirectionLeft;
    [self.view addGestureRecognizer:swipe];
    [swipe release];
    
    
    
    
    [self.scrollView release];
    
}

- (void)switchBitrateAction:(UISwipeGestureRecognizer *)swipe
{
    
    [self endButtonAction];
}


- (void)endButtonAction{
    UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    window.backgroundColor = [UIColor whiteColor];
    [window makeKeyAndVisible];
    
    [UMSocialData setAppKey:@"507fcab25270157b37000010"];
    [PlayerSingleton sharePlayerSingleton].playState = @"NO";
    MyMusicViewController *MyMusicVC = [[MyMusicViewController alloc] init];
    UINavigationController *myMusicNaviCon = [[UINavigationController alloc] initWithRootViewController:MyMusicVC];
    MyMusicVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的音乐" image:[UIImage imageNamed:@"iconfont-shouye"] tag:1000];
    myMusicNaviCon.navigationBar.translucent = NO;
    
    MusicLibraryViewController *musicLibraryVC = [[MusicLibraryViewController alloc] init];
    UINavigationController *musicLibNaviCon = [[UINavigationController alloc] initWithRootViewController:musicLibraryVC];
    musicLibraryVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"音乐库" image:[UIImage imageNamed:@"iconfont-yinle-3"] tag:2000];
    musicLibNaviCon.navigationBar.translucent = NO;
    
    RecommendViewController *recommendVC = [[RecommendViewController alloc] init];
    UINavigationController *recommendNaviCon = [[UINavigationController alloc] initWithRootViewController:recommendVC];
    recommendVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"推荐" image:[UIImage imageNamed:@"iconfont-tuijian"] tag:3000];
    recommendNaviCon.navigationBar.translucent = NO;
    
    SearchViewController *searchVC = [[SearchViewController alloc] init];
    UINavigationController *searchNaviCon = [[UINavigationController alloc] initWithRootViewController:searchVC];
    searchVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"搜索" image:[UIImage imageNamed:@"iconfont-sousuo"] tag:4000];
    searchNaviCon.navigationBar.translucent = NO;
    
    UITabBarController * tabBar = [[UITabBarController alloc]init];
    tabBar.viewControllers = [NSArray arrayWithObjects:myMusicNaviCon, musicLibNaviCon, recommendNaviCon, searchNaviCon, nil];
    window.rootViewController = tabBar;
    
    // number1
    [self.view addSubview:window];

    
    
    [musicLibraryVC release];
    [MyMusicVC release];
    [recommendVC release];
    [searchVC release];
    [window release];
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
